package Hash;

public class P12 {
    public static void main(String[] args) {
        P12Test01 p12Test01=new P12Test01();
        System.out.println(p12Test01.intToRoman(3749));
    }
}
/**
 * 整数转罗马数
 * 利用键值对的来存储，通过运算取值来获取罗马数
 *
 * */
class P12Test01{
    public static final String[][] R=new String[][]{
            {"","I","II","III","IV","V","VI","VII","VIII","IX"},
            {"","X","XX","XXX","XL","L","LX","LXX","LXXX","XC"},
            {"","C","CC","CCC","CD","D","DC","DCC","DCCC","CM"},
            {"","M","MM","MMM"}
    };

    public String intToRoman(int num) {
        return R[3][num/1000]+R[2][num/100%10]+R[1][num/10%10]+R[0][num%10];
    }
}
